package land;

import interfaces.Visible;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import abstracts.Level;

public class LandRow implements Visible {
    private BufferedImage img = null;
    private Rectangle.Double pos = new Rectangle.Double();

    public LandRow(double x, double y, double width, double height, Level level) {
        pos.x = x;
        pos.y = y;
        pos.width = width;
        pos.height = height;
        // img = new BufferedImage((int) width, (int) height,
        // BufferedImage.TYPE_INT_ARGB);

        // This is SUPPOSEDLY a "better" way to create an image...
        img = level.getApplet().getGraphicsConfiguration()
                .createCompatibleImage((int) width, (int) height,
                        Transparency.TRANSLUCENT);
    }

    public Graphics getGraphics() {
        return img.getGraphics();
    }

    @Override
    public void draw(Graphics g) {
        g.drawImage(img, (int) pos.x, (int) pos.y - 16, null);
    }

    @Override
    public double getDepth() {
        return pos.y;
    }
}
